package com.zou.application.config;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class ApplicationContextProvid implements ApplicationContextAware{
	
	private static ApplicationContext contentxt;
	
	public static ApplicationContext getApplicationContext() {
		return contentxt;
	}
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		contentxt = applicationContext;
	}
	
	public static <T> T getBean(Class<T> tClass){
		return contentxt.getBean(tClass);
	}
	
	public static <T> T getBean(String beanName,Class<T> tclClass){
		return contentxt.getBean(beanName, tclClass);
	}

}
